<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\facade\Cache;
use think\facade\Queue;

class Index extends Frontend
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        return $this->view->fetch();
    }

    public function news()
    {
        $newslist = [];

        return jsonp(['newslist' => $newslist, 'new' => count($newslist), 'url' => 'https://www.iuok.cn?ref=news']);
    }

    public function test(){
        print_r(session());
        $data =  Cache::get('session_8986a40221b8ccd525c8732091458bd4');
        print_r($data);
        print_r(unserialize($data));

        Cache::set('name','value',3600);
        echo Cache::get('name');
        $jobHandlerName = "app\job\Test";
        $jobQueueName = "testTask";
        //Queue::push($jobHandlerName, ['name'=>"5255"], $jobQueueName);
       // Queue::later('10',$jobHandlerName,['name'=>"52556"],$jobQueueName);
        echo "加入列队成功";

    }
    public function test2(){

        $jobHandlerName = "app\job\DevicePropertyNotify";
        $jobQueueName = "devProperNotify";
        //php think queue:work --queue devProperNotify
        Queue::push($jobHandlerName, ['imei'=>"test667","code"=>"h41xoormgiG","items"=>"1111"], $jobQueueName);
        //Queue::push($jobHandlerName, ['name'=>"5255"], $jobQueueName);
       // Queue::later('10',$jobHandlerName,['name'=>"52556"],$jobQueueName);
        echo "加入列队成功";

    }
}
